package com.itheima.dao;

import com.itheima.pojo.OrderSetting;
import com.itheima.pojo.OrderSettingDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface OrderSettingDao {
    /**
     * 根据日期修改可预约人数
     * @param orderSettingDTO
     * @return
     */
    @Update("update t_ordersetting set number=#{number} where orderDate=#{orderDate}")
    Integer editNumberByOrderDate(OrderSettingDTO orderSettingDTO);

    /**
     * 根据年月查询预约设置
     * @param begin
     * @param end
     * @return
     */
    @Select("select * from t_ordersetting where orderDate between #{begin} and #{end}")
    List<OrderSetting> getOrderSettingByMonth(LocalDate begin, LocalDate end);

    /**
     * 根据日期查询预定设置
     * @param orderDate
     * @return
     */
    @Select("select * from t_ordersetting where orderDate=#{orderDate}")
    OrderSetting getByOrderDate(LocalDate orderDate);

    /**
     * 插入日期设置
     * @param orderSettingDTO
     * @return
     */
    @Insert("insert into t_ordersetting(orderDate, number) values (#{orderDate}, #{number})")
    Integer insert(OrderSettingDTO orderSettingDTO);
}
